/**
 * 
 */
package leetCode;

/**
 * @author zhong
 *
 */
public class Master {
	String secret;
	String[] wordlist;

	public int guess(String word) {
		if (word.equals(secret)) {
			return 6;
		}
		if (!cantan(word, wordlist)) {
			return -1;
		}
		int cnt = 0;
		for (int i = 0; i < 6; i++) {
			if (word.charAt(i) == secret.charAt(i)) {
				cnt++;
			}
		}
		return cnt;
	}

	private boolean cantan(String word, String[] wordlist2) {
		for (int i = 0; i < wordlist2.length; i++) {
			if (word.equals(wordlist2[i]))
				return true;
		}
		return false;
	}
}
